/**
 * es9 正则表达式扩展
 * . : 不能匹配多字节 unicode, 行终结符 \n r
 * 修饰符：g i m y u s(dotAll)
 * 
 * 
 * 
 */

 const reg = /./s           // s 开启 dotAll
 console.log(reg.test('\n'))
 console.log(reg.test('\r'))
 console.log(reg.test('\u{2028}'))
 console.log(reg.test('\u{2029}'))

 // 具名组匹配
 const date = /(\d{4})-(\d{2})-(\d{2})/.exec("2020-12-12")
 console.log(date[1],date[2], date[3])

 const reg2 = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/
 const date2 = reg2.exec("2020-12-12")
 const {year,month, day} = date2.groups
 console.log(year,month, day)


 const str = 'ecmascript'
 console.log(str.match(/ecma(?=script)/)) // 先行断言  前面确定

 console.log(str.match(/(?<=ecma)script/))  // 后行断言 后面确定
 console.log(str.match(/(?<!=ecma)script/)) 